package com.fingard.dsp.bank.reqrespobj.authcancelforrec;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.authcancelforrec.detail.RetAtsQryRecAuthCancelInfoDetail;
import com.fingard.dsp.bank.reqrespobj.authforrec.detail.RetAtsQryRecAuthInfoDetail;
import com.fingard.xml.XmlTextWriter;

public class RetAtsQryRecAuthCancelInfo extends RetAtsBase {
    public RetAtsQryRecAuthCancelInfo(ReqRespHeader p_header) {
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();//用于输出返回ATS的XML报文
    }

    public String respCode;
    public String respInfo;
    public String ownAct;

    private boolean hasWrittenBefore = false;

    public void writeBeforeDetail() throws Exception {
        if (hasWrittenBefore) {
            throw new Exception("writeBeforeDetail已被调用过");
        }
        writeStart();//写返回ATS的统一头部信息
        retXmlWriter.writeElementString("RespCode", respCode);
        retXmlWriter.writeElementString("RespInfo", respInfo);
        retXmlWriter.writeElementString("RecAct", ownAct);
        hasWrittenBefore = true;
    }

    public void writeRetDetail(RetAtsQryRecAuthCancelInfoDetail p_detail) throws Exception {
        if (!hasWrittenBefore) {
            writeBeforeDetail();
        }
        retXmlWriter.writeStartElement("DetailRecord");
        retXmlWriter.writeElementString("PayAct", p_detail.oppAct);
        retXmlWriter.writeElementString("PayName", p_detail.oppActName);
        retXmlWriter.writeElementString("PayCur", p_detail.oppActCur);
        retXmlWriter.writeElementString("QueryTag", p_detail.queryTag);
        retXmlWriter.writeElementString("AuthDateFrom", p_detail.authDateFrom);
        retXmlWriter.writeElementString("RespReserve1", p_detail.respReserve1);
        retXmlWriter.writeElementString("RespReserve2", p_detail.respReserve2);
        retXmlWriter.writeElementString("RespReserve3", p_detail.respReserve3);
        retXmlWriter.writeEndElement();
    }

    public void writeAfterDetail() throws Exception {
        if (!hasWrittenBefore) {
            writeBeforeDetail();
        }
        writeEnd();//写结束
    }
}
